#pragma once

#include <algorithm>
#include <list>
#include <map>
#include <mutex>
#include <string>

#include "bondlib.h"

typedef struct _tag_QBSWSECTORINFO {
  char SW_Internal_Code[16 + 1];     // 行业代码
  char SW_Level;                     // 行业level
  char SW_Name[64 + 1];              // 行业中文名称
  char SW_English_Name[64 + 1];      // 行业英文名称
  char SW_Upper_Grade_Code[16 + 1];  // 上级行业代码
} QBSWSECTORINFO;

class S_BONDLIB_EXPORT CQBSwSectorInfo {
 public:
  static CQBSwSectorInfo& instance();
  static CQBSwSectorInfo& instance2021();

 public:
  std::map<std::string, QBSWSECTORINFO>& GetAllSwSectorInfo() { return m_map; }

  const QBSWSECTORINFO* GetSwSectorInfo(const std::string& id);

  bool Add(QBSWSECTORINFO& info);
  bool Clear();

 public:
  void DumpStatus(int mode = 0) const;

 private:
  CQBSwSectorInfo();
  virtual ~CQBSwSectorInfo();

 protected:
  std::map<std::string, QBSWSECTORINFO> m_map;
  std::mutex m_mutex;
};
